using BSDS.Core.Infrastructure.Logging;
using BSDS.Core.Model.Services;

namespace BSDS.Commands.Commands.Implementation
{
    public class SchemaCommand : CommandBase
    {
        private readonly string dataSourceName;
        private readonly AccountService accountService;
        private readonly Logger logger;

        public SchemaCommand(AccountService accountService, Logger logger, string dataSourceName)
        {
            this.accountService = accountService;
            this.logger = logger;

            this.dataSourceName = dataSourceName;
        }

        public override CommandResult Execute(ExecutionContext context)
        {
            var result = accountService.DownloadSchema(dataSourceName);

            logger.Log(result);

            return CommandResult.Success();
        }
    }
}